package ua.edu.nuos.jeetraining2012.cms.dto;

import com.google.api.services.calendar.model.EventAttendee;
import ua.edu.nuos.jeetraining2012.cms.dto.predefined.google.calendar.StandardGoogleCalendarEventReminders;
import ua.edu.nuos.jeetraining2012.cms.dto.predefined.google.calendar.StandardGoogleCalendarEventStatuses;
import ua.edu.nuos.jeetraining2012.cms.dto.predefined.google.calendar.StandardGoogleCalendarEventVisibility;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * DTO object for Google Calendar Events.
 *
 * @author Victor N. Ganichev victor.ganichev@gmail.com
 * @version 1.0 Date: 24.07.13 Time: 22:18
 * @since 1.0
 */
public class GoogleCalendarEventDTO implements Serializable {

    /** Define Google Calendar ID. */
    private String calendarId;

    /** Define Google Calendar's event ID. */
    private String eventId;

    /** Define event title. */
    private String eventTitle;

    /** Define event description. */
    private String eventDescription;

    /** Define event geographical location. */
    private String eventLocation;

    /**
     * Define event status.<br/>
     * Default is tentative confirmed.<br/>
     * More possible statuses {@link StandardGoogleCalendarEventStatuses}
     */
    private String eventStatus = StandardGoogleCalendarEventStatuses.EVENT_STATUS_TENTATIVE;

    /** Define event organizer. */
    private String eventOrganizer;

    /** Define event start. Date / Time. */
    private java.util.Date eventStart;

    /** Define event end. Date / Time. */
    private java.util.Date eventEnd;

    /**
     * Define event visibility.<br/>
     * Default is visible for everyone. I.e., event is public.<br/>
     * More possible visibility statuses see {@link StandardGoogleCalendarEventVisibility}.
     */
    private String eventVisibility = StandardGoogleCalendarEventVisibility.EVENT_VIS_PUBLIC;

    /**
     * Define event reminder.<br/>
     * Default is remind by email.<br/>
     * All possible reminders see {@link StandardGoogleCalendarEventReminders}.
     */
    private String eventReminder = StandardGoogleCalendarEventReminders.EVENT_REMINDER_EMAIL;

    /**
     * Define remind interval.
     * Do notify for <code>eventReminderMinutes</code> minutes before event.
     */
    private Integer eventReminderMinutes = 30;

    /**
     * Define event attendee.
     * At least one person should be presents.
     */
    private List<EventAttendee> attendeesList;

    /** Direct URL for event, this will be set, when event will be created. */
    private String eventLink;

    /**
     * Whether attendees other than the organizer can see who the event's attendees are. Optional.
     * The default is True.
     */
    private boolean guestToGuestVisibility = true;

    // Constructors.
    public GoogleCalendarEventDTO() {}

    // Getters & Setters.
    public String getCalendarId() {
        return calendarId;
    }

    public void setCalendarId(String calendarId) {
        this.calendarId = calendarId;
    }

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public String getEventTitle() {
        return eventTitle;
    }

    public void setEventTitle(String eventTitle) {
        this.eventTitle = eventTitle;
    }

    public String getEventDescription() {
        return eventDescription;
    }

    public void setEventDescription(String eventDescription) {
        this.eventDescription = eventDescription;
    }

    public String getEventLocation() {
        return eventLocation;
    }

    public void setEventLocation(String eventLocation) {
        this.eventLocation = eventLocation;
    }

    public String getEventStatus() {
        return eventStatus;
    }

    public void setEventStatus(String eventStatus) {
        this.eventStatus = eventStatus;
    }

    public String getEventOrganizer() {
        return eventOrganizer;
    }

    public void setEventOrganizer(String eventOrganizer) {
        this.eventOrganizer = eventOrganizer;
    }

    public Date getEventStart() {
        return eventStart;
    }

    public void setEventStart(Date eventStart) {
        this.eventStart = eventStart;
    }

    public Date getEventEnd() {
        return eventEnd;
    }

    public void setEventEnd(Date eventEnd) {
        this.eventEnd = eventEnd;
    }

    public String getEventVisibility() {
        return eventVisibility;
    }

    public void setEventVisibility(String eventVisibility) {
        this.eventVisibility = eventVisibility;
    }

    public String getEventReminder() {
        return eventReminder;
    }

    public void setEventReminder(String eventReminder) {
        this.eventReminder = eventReminder;
    }

    public List<EventAttendee> getAttendeesList() {
        return attendeesList;
    }

    public void setAttendeesList(List<EventAttendee> attendeesList) {
        this.attendeesList = attendeesList;
    }

    public Integer getEventReminderMinutes() {
        return eventReminderMinutes;
    }

    public void setEventReminderMinutes(Integer eventReminderMinutes) {
        this.eventReminderMinutes = eventReminderMinutes;
    }

    public String getEventLink() {
        return eventLink;
    }

    public void setEventLink(String eventLink) {
        this.eventLink = eventLink;
    }

    public boolean isGuestToGuestVisibility() {
        return guestToGuestVisibility;
    }

    public void setGuestToGuestVisibility(boolean guestToGuestVisibility) {
        this.guestToGuestVisibility = guestToGuestVisibility;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GoogleCalendarEventDTO that = (GoogleCalendarEventDTO) o;

        if (calendarId != null ? !calendarId.equals(that.calendarId) : that.calendarId != null) return false;
        if (eventId != null ? !eventId.equals(that.eventId) : that.eventId != null) return false;
        if (!eventTitle.equals(that.eventTitle)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = calendarId != null ? calendarId.hashCode() : 0;
        result = 31 * result + (eventId != null ? eventId.hashCode() : 0);
        result = 31 * result + eventTitle.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "GoogleCalendarEventDTO {" +
                "calendarId='" + calendarId + '\'' +
                ", eventId='" + eventId + '\'' +
                ", eventTitle='" + eventTitle + '\'' +
                ", eventDescription='" + eventDescription + '\'' +
                ", eventStatus='" + eventStatus + '\'' +
                ", eventOrganizer='" + eventOrganizer + '\'' +
                ", eventStart='" + eventStart + '\'' +
                ", eventEnd='" + eventEnd + '\'' +
                ", eventVisibility='" + eventVisibility + '\'' +
                ", eventReminder='" + eventReminder + '\'' +
                '}';
    }
}
